<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../assets/css/common.css">
    <link rel="stylesheet" href="../assets/css/vue.css">
    <script src="../assets/js/vue.js"></script>
    <script src="../assets/js/jquery.js"></script>
</head>
<body>
<a href="../index.html" class="retu">BACK</a>
<h1>实例方法</h1>
<p><button onclick="destory()">卸载</button></p>
<p><button onclick="upda()">更新</button></p>
<p><button onclick="tick()">数据修改</button></p>
<div id="app">

<!--    <span>{{ message }}</span>-->

</div>

<script type="text/javascript">
    var jspang = Vue.extend({
        template:`<p>{{ message }}</p>`,
        data:function () {
            return {
                message : 'hello I am jspang'
            }
        },
        destroyed:function () {
            console.log('已经被卸载了');
        },
        updated:function(){
            console.log('数据已经被更新了');
        }
    });
    var vm = new jspang().$mount('#app');
    function destory(){
        vm.$destroy();
    }


    function upda() {
        vm.$forceUpdate();
    }


    function tick() {
        vm.message = "update message info";
        vm.$nextTick(function () {
            console.log('message更新完成后我被调用了');
        })
    }
</script>
</body>
</html>